
define(["WebPDF",
		"PDFApiProvider",
		"PDFConfigProvider",
		'i18nProvider',
        'PDFView',
        'Plugins/Hand',   
        "Plugins/Form",
        "Plugins/Annot"],
        function(WebPDF) {   
        'use strict';	
	$.fn.pdfViewer = function(settings)
	{    
		return this.each(
			function()
			{
				var elem = $(this), pdfApi = elem.data('jsp');
				if (pdfApi) {					
				} else {
					WebPDF.config(['PDFConfigProvider', 'PDFApiProvider', 'i18nProvider',  function (PDFConfigProvider, PDFApiProvider, i18nProvider) {  
						PDFConfigProvider._s3Key = settings.s3Key;	
						PDFConfigProvider._baseUrl = '/app/pdfdata/';					
						PDFApiProvider.pdfViewer = elem;
						i18nProvider.init({
							language: "en-US",
							baseUrl: "/app/",
						}, function(){
							$("body").i18n();
						});

     				}]);  
					elem.attr('pdfdocviewer', "").attr("ng-controller", "PDFDocViewerController");
					var modules = ['WebPDF', 'FormPlugin', 'HandPlugin', "AnnotPlugin"];
					var injector = angular.bootstrap(this, modules);    
					pdfApi = injector.get("PDFApi");				
					elem.data('jsp', pdfApi);
				}
				return false;
			}
		);
	};


	$.fn.pdfViewer.defaults = {		
	};		
});